﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TSLP
    {

        public TSLP()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VLAGPL();
            DataContext = MV;  
            InitializeComponent();  
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "".PadRight(12);
                LP = "".PadRight(8);
            }
            else
            {
                KEY = dwMaster["LPLO"].ToString() + dwMaster["LPLB"].ToString() + dwMaster["LPPLATZ"].ToString();
                LP = dwMaster["LPPLATZ"].ToString();
            }
        }
        public override void LOADBYAUF()
        {        
            Locate("KLP", ORDERNUM); 
        } 
        public override void OnLPLBChg(string value)
        {
            TBMain.Clear();
            if (value.Length < 4)
                return;
            dwData = TBMain.NewRow();
            dwData["LPMANDANT"] = app.Mandant;
            dwData["LPLO"] = "AND LPLO='" + value.Substring(0, 2) + "'";
            dwData["LPLB"] = "AND LPLB='" + value.Substring(2, 2) + "'";
            dwData["LPPLATZ"] = "AND LPPLATZ LIKE '%'";
            SResult = ((VLAGPL)MV).QueryLAGPL(dwData, -1);
            MergeData(SResult, false);
        } 
    }
}
